package practice1;

public class Move extends Thread{

    static int ticket = 0;

    @Override
    public void run() {
        while(true){// 循环
            synchronized (Move.class){//同步代码块
                if(ticket == 1000){
                    break;
                }else{
                    ticket++;
                    System.out.println(getName()+"窗口卖出了第"+ticket+"张票,还剩"+(1000-ticket)+"张票");
                    try {
                        Thread.sleep(3000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        }
    }
}
